import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import WindiCSS from 'vite-plugin-windicss'
import DefineOptions from 'unplugin-vue-define-options/vite';
import path from "path"
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
// https://vitejs.dev/config/
export default defineConfig({
  server: {
    open: '/index.html',
    host: '0.0.0.0',
    proxy: {
      '/api': {
        target: 'http://192.168.10.27:31600',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
    }
  },

  plugins: [vue(), WindiCSS(), DefineOptions(),
  createSvgIconsPlugin({
    // 指定需要缓存的图标文件夹
    iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')],
    // 指定symbolId格式
    symbolId: '[name]',
  })
  ],
  // base:process.env.NODE_ENV === 'development'?'':'/tzl-app/',
  resolve: {
    alias: {
      "~": path.resolve(__dirname, "src")
    }
  },
  build: {
    minify: 'terser',
    terserOptions: {
      compress: {
        drop_console: true,
        drop_debugger: true
      }
    }
  }
})
